<?

class Smutty_GPG_ValidSignature {

	var $text, $name, $keyId;

	/**
	 *  constructor.  the input should be an array of lines which
	 *  are the output of a successful attempt to verify a pgp sig.
	 *
	 *  @param [results] array of strings
	 *
	 */

	function Smutty_GPG_ValidSignature( $results ) {

		$this->text = implode( "\n", $results );

		// contains names of properties, and a regexp
		// which will extract that prop from $results
		$props = array(
			name => '/signature from "(.+)"/',
			keyId => '/key ID ([A-Z0-9]+)/'
		);

		// extract properties from results
		foreach ( $props as $key => $regexp )
			foreach ( $results as $line )
				if ( preg_match($regexp,$line,$matches) )
					$this->$key = $matches[1];

	}

	/**
	 *  returns the complete text of the verify result
	 *
	 *  @return String
	 *
	 */

	function getText() {
		return $this->text;
	}

	/**
	 *  returns the name associated with the sig
	 *
	 *  @return String
	 *
	 */

	function getName() {
		return $this->name;
	}

	/**
	 *  returns the keys id
	 *
	 *  @return String
	 *
	 */

	function getKeyId() {
		return $this->keyId;
	}

}

?>